# 按钮控制led灯

import luinit
from usb2gpio import usb2gpio
import ctypes

# 把打开设备等初始化的语句放入init函数里, 返回值是DevHandle
DevHandle = luinit.init()
print(DevHandle)

pin_btn = 0b10
pin_blue = 0b01
btn_value = ctypes.c_uint(0)
usb2gpio.GPIO_SetOutput(DevHandle, pin_blue, 0)
usb2gpio.GPIO_SetInput(DevHandle, pin_btn, 0)
while True:
    usb2gpio.GPIO_Read(DevHandle, pin_btn, ctypes.byref(btn_value))
    if not btn_value:
        usb2gpio.GPIO_Write(DevHandle, pin_blue, 0b01)
    else:
        usb2gpio.GPIO_Write(DevHandle, pin_blue, 0)
    # ret= usb2gpio.GPIO_Write(DevHandle,pin_blue,0b01)
